package org.jinyan.admin.controller;

import java.sql.SQLException;
import java.util.List;

import org.jinyan.admin.model.MyUser;
import org.jinyan.db.dao.impl.UserDBMapDao;

public class UserController {
	private UserDBMapDao userDao = new UserDBMapDao();

	public MyUser login(String userUuid, String pwd) throws SQLException {
		MyUser user = new MyUser();
		user.setUseruuid(userUuid);
		user.setPassword(pwd);
		System.out.println("UserController 用户登录验证");
		return userDao.select(user);
	}

	public boolean addUser(String userUuid, String userName, String pwd,
			String email) throws SQLException {
		System.out.println("用户添加 开始" + userUuid);
		MyUser user = new MyUser();
		user.setUseruuid(userUuid);
		user.setUsername(userName);
		user.setPassword(pwd);
		user.setEmail(email);
		System.out.println("用户添加 结束" + userUuid);
		return userDao.add(user);
	}

	public boolean addUser(String userUuid, String userName, String pwd,
			String email, String userType) throws SQLException {
		MyUser user = new MyUser();
		user.setUseruuid(userUuid);
		user.setUsername(userName);
		user.setPassword(pwd);
		user.setEmail(email);
		user.setUsertype(userType);
		return userDao.add(user);
	}
	
	public List<MyUser> getAllUser() throws SQLException{
		return userDao.listUsers();
	}
	
	public boolean deleteById(String id) throws SQLException{
		return userDao.deleteById(id);
	}

}
